package com.ruoyi.dataSys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dataSys.domain.ShipsData;
import com.ruoyi.dataSys.service.IShipsDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 船舶信息管理Controller
 * 
 * @author ruoyi
 * @date 2024-11-28
 */
@RestController
@RequestMapping("/dataSys/ships")
public class ShipsDataController extends BaseController
{
    @Autowired
    private IShipsDataService shipsDataService;

    /**
     * 查询船舶信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('dataSys:ships:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShipsData shipsData)
    {
        startPage();
        List<ShipsData> list = shipsDataService.selectShipsDataList(shipsData);
        return getDataTable(list);
    }

    /**
     * 导出船舶信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('dataSys:ships:export')")
    @Log(title = "船舶信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShipsData shipsData)
    {
        List<ShipsData> list = shipsDataService.selectShipsDataList(shipsData);
        ExcelUtil<ShipsData> util = new ExcelUtil<ShipsData>(ShipsData.class);
        util.exportExcel(response, list, "船舶信息管理数据");
    }

    /**
     * 获取船舶信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('dataSys:ships:query')")
    @GetMapping(value = "/{shipNameCn}")
    public AjaxResult getInfo(@PathVariable("shipNameCn") String shipNameCn)
    {
        return success(shipsDataService.selectShipsDataByShipNameCn(shipNameCn));
    }

    /**
     * 新增船舶信息管理
     */
    @PreAuthorize("@ss.hasPermi('dataSys:ships:add')")
    @Log(title = "船舶信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShipsData shipsData)
    {
        return toAjax(shipsDataService.insertShipsData(shipsData));
    }

    /**
     * 修改船舶信息管理
     */
    @PreAuthorize("@ss.hasPermi('dataSys:ships:edit')")
    @Log(title = "船舶信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShipsData shipsData)
    {
        return toAjax(shipsDataService.updateShipsData(shipsData));
    }

    /**
     * 删除船舶信息管理
     */
    @PreAuthorize("@ss.hasPermi('dataSys:ships:remove')")
    @Log(title = "船舶信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shipNameCns}")
    public AjaxResult remove(@PathVariable String[] shipNameCns)
    {
        return toAjax(shipsDataService.deleteShipsDataByShipNameCns(shipNameCns));
    }
}
